/*
 * SDNCreateAlbumsViewController
 * @description 本文件提供创建相册或修改相册属性的ViewController
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供创建相册或修改相册属性的ViewController
 */

#import "SDNCreateAlbumsViewController.h"
#import "ExampleNestedTablesViewController.h"
#import "SelectPermissionsCell.h"
#import "SD_New_groupViewController.h"
#import "SDN_Q_S_ViewController.h"
#import "LeveyTabBarController.h"
#import "BanBu_NestTableController.h"
#import "BanBu_NavigationController.h"
#import "TKLoadingView.h"
#import "AppCommunicationManager.h"
#import "AppDataManager.h"

@interface SDNCreateAlbumsViewController ()
{
    //创建按钮，过程中会发生变化，需要设置全局
    UIButton *_createBu;
}
@end

@implementation SDNCreateAlbumsViewController

//修改：yinlinlin
@synthesize album_model = _album_model;
- (void)dealloc
{
    _album_model = nil;
    _openGroup = nil;
    _hideGroup = nil;
    _questionStr = nil;
    _answerStr = nil;
    _parDic = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    if (self.tableView)
    {
        NSIndexPath * indexPath = [NSIndexPath indexPathForRow:_selectTag inSection:1];
        [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
    }
    [super viewWillAppear:animated];
    
}
//修改完成：yinlinlin

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.tableView.scrollEnabled = NO;
        self.title = NSLocalizedString(@"album_create1", 创建相册);
    }
    return self;
}
-(void)viewDidLoad
{
    [super viewDidLoad];
    //    _titleArr = [[NSArray alloc]initWithObjects:@"Competence_everyone",@"Competence_myself",@"Competence_qs",@"Competence_designess",@"Competence_notdesigness", nil];
    _titleArr = [[NSArray alloc]initWithObjects:@"Competence_everyone",@"Competence_notdesigness",@"Competence_qs",@"Competence_myself", nil];
    //最多10个分组
    self.view.backgroundColor = UIColorToRGB(0xf0f2f4);
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    //主要是修改相册属性把修改的数据传到上一界面
    _parDic = [[NSMutableDictionary alloc]init];
    self.tableView.backgroundColor = UIColorToRGB(0xf0f2f4);
    _openGroup = [[NSMutableArray alloc]initWithCapacity:50];
    _hideGroup = [[NSMutableArray alloc]initWithCapacity:50];
    _questionStr = [[NSMutableString alloc]init];
    _answerStr = [[NSMutableString alloc]init];
    _createBu = [UIButton buttonWithType:UIButtonTypeCustom];
    [_createBu setTitle:NSLocalizedString(@"confirmNotice", 确定) forState:UIControlStateNormal];
    [_createBu setFrame:CGRectMake(0, 0, 60, 35)];
    _createBu.userInteractionEnabled = NO;
    [_createBu setTitleColor:UIColorWithRGB(255, 255, 255, 0.5) forState:UIControlStateNormal];
    _createBu.titleLabel.font = [UIFont systemFontOfSize:16.0];
    [_createBu addTarget:self action:@selector(createAlbum) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * createItem = [[UIBarButtonItem alloc]initWithCustomView:_createBu];
    self.navigationItem.rightBarButtonItem = createItem;
    
    //修改：yinlinlin
    
    _AlmNam = [[UITextField alloc]initWithFrame:CGRectMake(75, 15, 200, 15)];
    _AlmNam.font = [UIFont systemFontOfSize:14.0];
    _AlmNam.placeholder = NSLocalizedString(@"album_title_notice1", 相册名称);
    _AlmNam.delegate = self;
    _AlmNam.backgroundColor = UIColorToRGB(0xffffff);
    _AlmNam.returnKeyType = UIReturnKeyDone;
    
    [_AlmNam addTarget:self action:@selector(textFieldChangeEdit:) forControlEvents:UIControlEventEditingChanged];
    
    
    
    if (!_album_model)
    {
        //创建相册
        _indexTag = ALBUM_CREATE;
        self.title = NSLocalizedString(@"createAlbum", 创建相册);
        NSIndexPath * indexPath = [NSIndexPath indexPathForRow:0 inSection:1];
        [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
    }
    else
    {
        //修改相册属性
        _indexTag = ALBUM_CHANGE;
        self.title = NSLocalizedString(@"album_albumProper", 相册属性);
        //        NSInteger row = 0;
        //        if (_album_model.personalbum_type == CREATE_PRIVATE)
        //        {
        //            row = 1;
        //        }
        //        else if (_album_model.personalbum_type == CREATE_QUESSTION)
        //        {
        //            row = 2;
        //        }
        //        else if (_album_model.personalbum_type == CREATE_OPENGROUP)
        //        {
        //            row = 3;
        //        }
        //        else if ( _album_model.personalbum_type == CREATE_HIDEGROUP)
        //        {
        //            row = 4;
        //        }
        if (_album_model.personalbum_type == CREATE_PUBLIC)
        {
            _selectTag = 0;
        }
        else if (_album_model.personalbum_type == CREATE_HIDEGROUP)
        {
            _selectTag = 1;
        }
        else if (_album_model.personalbum_type == CREATE_QUESSTION)
        {
            _selectTag = 2;
        }
        else if (_album_model.personalbum_type == CREATE_PRIVATE)
        {
            _selectTag = 3;
        }
        else
        {
            _selectTag = 4;
        }
        //        _selectTag = _album_model.personalbum_type;
        NSIndexPath * indexPath = [NSIndexPath indexPathForRow:_album_model.personalbum_type inSection:1];
        [self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
        if (_album_model.question) {
            [_questionStr appendString:_album_model.question];
        }
        if (_album_model.answer) {
            [_answerStr appendString:_album_model.answer];
        }
        if (_album_model.personalbum_type == CREATE_OPENGROUP)
        {
            _album_model.opengroup = [_album_model.opengroup substringToIndex:_album_model.opengroup.length - 1];
            [_openGroup addObjectsFromArray:[_album_model.opengroup componentsSeparatedByString:@","]];
            
        }
        else if (_album_model.personalbum_type == CREATE_HIDEGROUP)
        {
            _album_model.hidegroup = [_album_model.hidegroup substringToIndex:_album_model.hidegroup.length - 1];
            [_hideGroup addObjectsFromArray:[_album_model.hidegroup componentsSeparatedByString:@","]];
        }
        
    }
    
    if (_indexTag == 1)
    {
        _AlmNam.text = _album_model.album_title;
        _createBu.userInteractionEnabled = YES;
        [_createBu setTitleColor:UIColorWithRGB(255, 255, 255, 1.0) forState:UIControlStateNormal];
        _createBu.titleLabel.font = [UIFont systemFontOfSize:16.0];
    }
    //修改完成：yinlinlin
    
}

#pragma mark - 创建相册或修改相册属性的方法
- (void)createAlbum
{
    //创建相册
    if (_indexTag == ALBUM_CREATE)
    {
        if (self.AlmNam.text.length > 0)
        {
            NSDictionary * parDic = nil;
            //        NSString * nameStr = [[_AlmNam.text dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString];
            //公开相册
            if (_selectTag == 0)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",@"-all-",@"opengroup",@"0",@"stringof", nil];
                NSLog(@"公开相册:%@",parDic);
            }
            //私密相册
            else if (_selectTag == 3)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",@"-all-",@"hidegroup",@"1",@"stringof",  nil];
                NSLog(@"私密相册:%@",parDic);
            }
            //回答问题可见相册
            else if (_selectTag == 2)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",_questionStr,@"byquestion",_answerStr,@"answerof",@"2",@"stringof", nil];
                NSLog(@"回答问题可见:%@",parDic);
            }
            //指定分组可见
            else if (_selectTag == 4)
            {
                NSMutableString * openArr = [NSMutableString string];
                for (NSString * groupName in _openGroup)
                {
                    [openArr appendFormat:@"%@,",groupName];
                }
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",openArr,@"opengroup",@"3",@"stringof", nil];
                NSLog(@"指定人可见相册:%@",parDic);
            }
            //指定分组不可见
            else if (_selectTag == 1)
            {
                NSMutableString * hideArr = [NSMutableString string];
                for (NSString * groupName in _hideGroup)
                {
                    [hideArr appendFormat:@"%@,",groupName];
                }
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",hideArr,@"hidegroup",@"4",@"stringof", nil];
                NSLog(@"指定人不可见相册:%@",parDic);
                
            }
            [_parDic addEntriesFromDictionary:parDic];
            [AppComManager getBanBuData:BanBu_v2_Create_Album_Byuser par:_parDic delegate:self];
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"loadingNotice", nil) activityAnimated:YES];
        }
    }
    //修改相册属性
    else
    {
        if (self.AlmNam.text.length > 0)
        {
            NSDictionary * parDic = nil;
            //        NSString * nameStr = [[_AlmNam.text dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString];
            //公开相册
            if (_selectTag == 0)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",@"-all-",@"opengroup",@"0",@"stringof",_album_model.album_id,@"albumid", nil];
                NSLog(@"公开相册:%@",parDic);
            }
            //私密相册
            else if (_selectTag == 3)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",@"-all-",@"hidegroup",@"1",@"stringof",_album_model.album_id,@"albumid",  nil];
                NSLog(@"私密相册:%@",parDic);
            }
            //回答问题可见相册
            else if (_selectTag == 2)
            {
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",_questionStr,@"byquestion",_answerStr,@"answerof",@"2",@"stringof",_album_model.album_id,@"albumid", nil];
                NSLog(@"回答问题可见:%@",parDic);
            }
            //指定分组可见
            else if (_selectTag == 4)
            {
                NSMutableString * openArr = [NSMutableString string];
                for (NSString * groupName in _openGroup)
                {
                    if (groupName.length == 0)
                    {
                        [_openGroup removeObject:groupName];
                    }
                    else
                    {
                        [openArr appendFormat:@"%@,",groupName];
                    }
                }
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",openArr,@"opengroup",@"3",@"stringof",_album_model.album_id,@"albumid", nil];
                NSLog(@"指定人可见相册:%@",parDic);
            }
            //指定分组不可见
            else if (_selectTag == 1)
            {
                NSMutableString * hideArr = [NSMutableString string];
                for (NSString * groupName in _hideGroup)
                {
                    if (groupName.length == 0)
                    {
                        [_hideGroup removeObject:groupName];
                    }
                    else
                    {
                        [hideArr appendFormat:@"%@,",groupName];
                    }
                    
                    [hideArr appendFormat:@"%@,",groupName];
                }
                parDic = [NSDictionary dictionaryWithObjectsAndKeys:_AlmNam.text,@"pname",hideArr,@"hidegroup",@"4",@"stringof",_album_model.album_id,@"albumid", nil];
                NSLog(@"指定人不可见相册:%@",parDic);
                
            }
            [_parDic removeAllObjects];
            [_parDic addEntriesFromDictionary:parDic];
            
            
            [AppComManager getBanBuData:BanBu_v2_Modify_Album_Byuser par:parDic delegate:self];
            [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"loadingNotice", nil) activityAnimated:YES];
        }
    }
    
    
}

#pragma mark - 接口返回数据
- (void)banbuRequestDidFinished:(NSDictionary *)resDic error:(NSError *)error
{
    [TKLoadingView dismissTkFromView:self.navigationController.view animated:NO afterShow:0];
    
    if(error)
    {
        [TKLoadingView showTkloadingAddedTo:self.navigationController.view title:NSLocalizedString(@"network_error", nil) activityAnimated:NO duration:1];
    }
    if([AppComManager respondsDic:resDic isFunctionData:BanBu_v2_Create_Album_Byuser])
    {
        NSLog(@"创建相册返回内容:%@",resDic);
        if([[resDic valueForKey:@"ok"] boolValue])
        {
            [self.navigationController popViewControllerAnimated:YES];
            NSLog(@"创建相册成功");
            BanBu_AlbumModel * albumModel = [[BanBu_AlbumModel alloc]init];
            albumModel.album_id = [resDic valueForKey:@"albumid"];
            albumModel.album_type = ALBUM_PERSONAL;
            albumModel.album_title = [_parDic valueForKey:@"pname"];
            albumModel.image_url = nil;
            albumModel.faceIdStr = nil;
            albumModel.numCount = 0;
            albumModel.user_id = MyAppDataManager.useruid;
            albumModel.opengroup = [_parDic valueForKey:@"opengroup"];
            albumModel.hidegroup = [_parDic valueForKey:@"hidegroup"];
            albumModel.personalbum_type = [[_parDic valueForKey:@"stringof"] integerValue];
            albumModel.question = [_parDic valueForKey:@"byquestion"];
            albumModel.answer = [_parDic valueForKey:@"answerof"];
            if (_createSuccessCallBack)
            {
                //将新相册的ID传到上一界面，主要是转移照片需要使用id
                _createSuccessCallBack(albumModel);
            }
            
        }
        return;
        
    }
    else if ([AppComManager respondsDic:resDic isFunctionData:BanBu_v2_Modify_Album_Byuser])
    {
        NSLog(@"修改相册返回内容:%@",resDic);
        if([[resDic valueForKey:@"ok"] boolValue])
        {
            _album_model.album_title = _AlmNam.text;
            _album_model.personalbum_type = [[_parDic valueForKey:@"stringof"]intValue];
            _album_model.opengroup = [_parDic valueForKey:@"opengroup"];
            _album_model.hidegroup = [_parDic valueForKey:@"hidegroup"];
            _album_model.question = [_parDic valueForKey:@"byquestion"];
            _album_model.answer = [_parDic valueForKey:@"answerof"];
            __weak BanBu_AlbumModel * balbum_model = _album_model;
            
            [self.navigationController popViewControllerAnimated:YES];
            NSLog(@"修改相册成功");
            if (_changeSuccessCallBack)
            {
                _changeSuccessCallBack(balbum_model);
            }
            if (_createSuccessCallBack)
            {
                //将新相册的ID传到上一界面，主要是转移照片需要使用id
                _createSuccessCallBack(balbum_model);
            }
            
        }
        
    }
    
}


#pragma mark - UITableViewDelegate
#pragma mark - UITableViewDelegate
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        static NSString * section0Identifier = @"section0";
        UITableViewCell * cell0 = [tableView dequeueReusableCellWithIdentifier:section0Identifier];
        if (!cell0)
        {
            cell0 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:section0Identifier];
            cell0.contentView.backgroundColor = UIColorToRGB(0xffffff);
        }
        for (UIView * views in cell0.contentView.subviews)
        {
            [views removeFromSuperview];
        }
        [cell0.contentView addSubview:[BanBu_CommentMethod cuttingLineWithOriginx:0 andOriginY:0]];
        [cell0.contentView addSubview:[BanBu_CommentMethod cuttingLineWithOriginx:0 andOriginY:45.5]];
        UILabel * nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 15, 100, 17)];
        nameLabel.text = NSLocalizedString(@"albumName", 相册名称);
        nameLabel.font = [UIFont systemFontOfSize:14];
        [nameLabel sizeToFit];
        nameLabel.backgroundColor = UIColorToRGB(0xffffff);
        [cell0.contentView addSubview:nameLabel];
        [_AlmNam setFrame:CGRectMake(22 + nameLabel.frame.size.width, 15, __MainScreen_Width - 22 - nameLabel.frame.size.width, 17)];
        [cell0 addSubview:_AlmNam];
        cell0.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell0;
        
    }
    static NSString *CellIdentifier = @"SelectPremission";
    SelectPermissionsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if(cell == nil){
        cell = [[[NSBundle mainBundle] loadNibNamed:@"SelectPremissions"  owner:self options:nil] lastObject];
        cell.backgroundColor = UIColorToRGB(0xffffff);
        cell.contentView.backgroundColor = UIColorToRGB(0xffffff);
    }
    //    cell.textLabel.font = [UIFont systemFontOfSize:15];
    //    if (indexPath.row == 0 && indexPath.section ==0)
    //    {
    //        cell.textLabel.text = NSLocalizedString(@"albumName", 相册名称);
    //        _AlmNam = [[UITextField alloc]init];
    //        _AlmNam.delegate = self;
    //        _AlmNam.frame = CGRectMake(90, 7, 220, 40);
    //        [cell addSubview:_AlmNam];
    ////        cell.accessoryType = UITableViewCellAccessoryNone;
    //    }
    if (indexPath.section == 1)
    {
        cell.selectitle.text = NSLocalizedString([_titleArr objectAtIndex:indexPath.row], nil);
        [cell.lineImgV setFrame:CGRectMake(20, 45.5, 300, 0.5)];
        if ((indexPath.row == 1) || (indexPath.row == 2))
        {
            //accessoryView在ios6始终和tableView的背景颜色相同，不能使用cell.accessoryType
            //            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            [cell.pushImgV setHidden:NO];
            if (indexPath.row  == 4)
            {
                [cell.lineImgV setFrame:CGRectMake(0, 45.5, 320, 0.5)];
            }
        }
        else
        {
            [cell.pushImgV setHidden:YES];
        }
    }
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //选中0section，选中无效
    if (indexPath.section == 0)
    {
        [tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:_selectTag inSection:1] animated:NO scrollPosition:UITableViewScrollPositionNone];
        return;
    }
    if (indexPath.section == 1)
    {
        [self.view endEditing:YES];
        
        if (indexPath.row == 0)//所有人可见
        {
            //当前选中的类型
            _selectTag = indexPath.row;
            
            
            return;
        }
        if (indexPath.row == 3)//仅自己可见
        {
            //当前选中的类型
            _selectTag = indexPath.row;
            return;
            
        }
        if (indexPath.row == 2)//回答问题可见
        {
            SDN_Q_S_ViewController * qav = [[SDN_Q_S_ViewController alloc]init];
            //修改：yinlinlin：
            [qav updateLastQuestion:_questionStr andAnswer:_answerStr];
            __weak NSMutableString * bquestion = _questionStr;
            __weak NSMutableString * banswer = _answerStr;
            [qav setQuestionAndanswerCallBack:^(NSString * newQuestion, NSString *newAnswer)
             {
                 //获取新的问题和答案
                 [bquestion setString:@""];
                 [bquestion appendString:newQuestion];
                 [banswer setString:@""];
                 [banswer appendString:newAnswer];
                 NSLog(@"新的问题和答案:%@ %@",bquestion,banswer);
                 _selectTag = 2;
             }];
            
            //修改完成：yinlinlin
            [self.navigationController pushViewController:qav animated:YES];
            return;
        }
        if (indexPath.row == 4)//指定好友可见
        {
            //修改：yinlinlin
            SD_New_groupViewController * svc = [[SD_New_groupViewController alloc]init];
            svc.preSelectedGroup = _openGroup;
            
            __weak NSMutableArray * bselectedGroup = _openGroup;
            [svc setSelectGroupCallBack:^(NSArray *selectGroup)
             {
                 [bselectedGroup removeAllObjects];
                 [bselectedGroup addObjectsFromArray:selectGroup];
                 _selectTag = 4;
             }];
            
            [self.navigationController pushViewController:svc animated:YES];
            return;
            //修改完成：yinlinlin
            //            ExampleNestedTablesViewController * evc = [[ExampleNestedTablesViewController alloc]init];
            //            UINavigationController * nvc = [[UINavigationController alloc]initWithRootViewController:evc];
            //
            //            [self presentModalViewController:nvc animated:YES];
            //            [self.navigationController pushViewController:evc animated:YES];
        }
        if (indexPath.row == 1)//指定好友不可见
        {
            SD_New_groupViewController * svc = [[SD_New_groupViewController alloc]init];
            svc.preSelectedGroup = _hideGroup;
            //修改：yinlinlin
            __weak NSMutableArray * bselectedGroup = _hideGroup;
            [svc setSelectGroupCallBack:^(NSArray *selectGroup)
             {
                 [bselectedGroup removeAllObjects];
                 [bselectedGroup addObjectsFromArray:selectGroup];
                 _selectTag = 1;
             }];
            //修改完成：yinlinlin
            [self.navigationController pushViewController:svc animated:YES];
            return;
        }
    }
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 1;
    }
    else     {
        return _titleArr.count;
    }
    return 6;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 46;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 15;
    }
    return 35;
    //    if (section ==0) {
    //        return 10;
    //    }
    //    if(section == 1)
    //    {
    //        return 48;
    //    }
    //    return 48;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        UIView * nilHeadrV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 10)];
        nilHeadrV.backgroundColor = UIColorToRGB(0xf0f2f4);
        return nilHeadrV;
    }
    UIView * headerV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 35)];
    UILabel * introLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 10, 200, 15)];
    introLabel.text = NSLocalizedString(@"Competence_album", 相册隐私);
    headerV.backgroundColor = UIColorToRGB(0xf0f2f4);
    introLabel.backgroundColor = UIColorToRGB(0xf0f2f4);
    introLabel.font = [UIFont systemFontOfSize:14.0];
    [headerV addSubview:introLabel];
    
    [headerV addSubview:[BanBu_CommentMethod cuttingLineWithOriginx:0 andOriginY:34.5]];
    return headerV;
    
}
//-(NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
//    NSString * headertitle;
//    if (section == 1) {
//        headertitle= NSLocalizedString(@"Competence_album", 相册隐私);
//    }
//    return headertitle;
//}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark UITextField Delegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    return YES;
}
//检测textfield的text变化，当拼音转化成汉字的时候可以检测到
- (void)textFieldChangeEdit:(UITextField *)sender
{
    if (sender.text.length <= 0)
    {
        _createBu.userInteractionEnabled = NO;
        [_createBu setTitleColor:UIColorWithRGB(255, 255, 255, 0.5) forState:UIControlStateNormal];
    }
    else
    {
        _createBu.userInteractionEnabled = YES;
        [_createBu setTitleColor:UIColorWithRGB(255, 255, 255, 1) forState:UIControlStateNormal];
        
    }
    if (sender.text.length > 30)
    {
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"album_titleNotice", 相册名称提示) message:NSLocalizedString(@"album_title_notice2", 相册名称) delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"confirmNotice", 确定), nil];
        [alert show];
        
    }
}


@end
